package com.wjy.game.viewer;

import javax.annotation.Resource;
import javax.swing.*;

import org.springframework.stereotype.Component;

/**
 * @author wjy
 * @date 2025/5/20 14:05
 * @description 注册视图
 * @version 1.0
 */
@Component
public class RegisterViewer extends ClientViewer {

    private JLabel countLabel = new JLabel("账    号 ");

    private JTextField countField = new JTextField(10);

    private JLabel userLabel = new JLabel("用 户 名 ");

    private JTextField userField = new JTextField(10);

    private JLabel passwordLabel = new JLabel("密    码 ");

    private JPasswordField passwordField = new JPasswordField(15);

    private JLabel rePasswordLabel = new JLabel("确认密码");

    private JPasswordField rePasswordField = new JPasswordField(15);

    private JButton registerButton = new JButton("注  册");

    private JButton loginButton = new JButton("登  录");

    @Resource
    private LoginViewer loginViewer;

    @Override
    protected void repaintUI() {

        countLabel.setBounds(50, 50, 50, 30);
        add(countLabel);
        countField.setBounds(100, 50, 150, 30);
        add(countField);
        userLabel.setBounds(50, 100, 50, 30);
        add(userLabel);
        userField.setBounds(100, 100, 150, 30);
        add(userField);
        passwordLabel.setBounds(50, 150, 50, 30);
        add(passwordLabel);
        passwordField.setBounds(100, 150, 150, 30);
        add(passwordField);
        rePasswordLabel.setBounds(50, 200, 50, 30);
        add(rePasswordLabel);
        rePasswordField.setBounds(100, 200, 150, 30);
        add(rePasswordField);
        registerButton.setBounds(25, 250, 250, 30);
        add(registerButton);
        loginButton.setBounds(195, 290, 80, 30);
        add(loginButton);
    }

    @Override
    protected void actions() {
        loginButton.addActionListener(e -> {
            this.setVisible(false);
            loginViewer.initUI();
        });
    }

    @Override
    public int getWidth() {
        return 300;
    }

    @Override
    public int getHeight() {
        return 400;
    }
}
